home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / tex / texchang.arc / tangle < prev    next >
Text File  |  1990-03-16  |  8KB  |  322 lines

  1. TANGLE change file for the Atari ST
  2. Author: Nico Poppelier.
  3. Date  : December 30, 1988.
  4.  
  5. Due to an error in the Prospero Pascal compiler the control variable
  6. of the FOR loops in sections 138, 182, and 184 are judged 'insecure',
  7. i.e., it looks as if they are modified by a routine.
  8. To avoid this 'error' a new loop variable k is introduced.
  9.  
  10. @x
  11. \pageno=\contentspagenumber \advance\pageno by 1
  12. @y
  13. \pageno=\contentspagenumber \advance\pageno by 1
  14. % \let\maybe=\iffalse
  15. % \def\title{TANGLE changes for the Atari ST}
  16. \def\title{TANGLE, Version 2.8 for the Atari ST}
  17. @z
  18.  
  19. @x
  20. @d banner=='This is TANGLE, Version 2.8'
  21. @y
  22. @d banner=='This is TANGLE, Version 2.8 for the Atari ST'
  23. @z
  24.  
  25. @x
  26. and the string pool output goes to file |pool|.
  27. @y
  28. and the string pool output goes to file |pool|.
  29. Prospero Pascal for the Atari ST requires us to mention
  30. |input| and |output| in the program header, too.
  31. They are used for terminal input and output.
  32. @z
  33.  
  34. @x
  35. program TANGLE(@!web_file,@!change_file,@!Pascal_file,@!pool);
  36. @y
  37. program TANGLE(@!input,@!output,
  38.                @!web_file,@!change_file,@!Pascal_file,@!pool);
  39. @z
  40.  
  41. @x
  42. procedure initialize;
  43. @y
  44. procedure wait(delay:real); external; {from doslib}@/
  45. procedure initialize;
  46. @z
  47.  
  48. @x
  49. @d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
  50. @d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
  51. @y
  52. @d debug== {we are debugging}
  53. @d gubed==
  54. @z
  55.  
  56. @x
  57. @d stat==@{ {change this to `$\\{stat}\equiv\null$'
  58.   when gathering usage statistics}
  59. @d tats==@t@>@} {change this to `$\\{tats}\equiv\null$'
  60.   when gathering usage statistics}
  61. @y
  62. @d stat== {we are gathering usage statistics}
  63. @d tats==
  64. @z
  65.  
  66. @x
  67. @<Compiler directives@>=
  68. @{@&$C-,A+,D-@} {no range check, catch arithmetic overflow, no debug overhead}
  69. @!debug @{@&$C+,D+@}@+ gubed {but turn everything on when debugging}
  70. @y
  71. On the Atari ST, things are different:
  72. Prospero Pascal does not allow in-comment directives
  73. @<Compiler directives@>=
  74. @z
  75.  
  76. @x
  77. @d othercases == others: {default for cases not listed explicitly}
  78. @y
  79. @d othercases == otherwise {default for cases not listed explicitly}
  80. @z
  81.  
  82. @x
  83. @!max_toks=50000; {|1/zz| times the number of bytes in compressed \PASCAL\ code;
  84.  
  85.   must be less than 65536}
  86. @y
  87. @!max_toks=51000; {|1/zz| times the number of bytes in compressed \PASCAL\ code;
  88.  
  89.   must be less than 65536}
  90. @z
  91.  
  92. @x
  93. @!text_file=packed file of text_char;
  94. @y
  95. @!text_file=text;
  96. @z
  97.  
  98. @x
  99. @d print(#)==write(term_out,#) {`|print|' means write on the terminal}
  100. @y
  101. @d term_in==input
  102. @d term_out==output
  103. @d print(#)==write(term_out,#) {`|print|' means write on the terminal}
  104. @z
  105.  
  106. @x
  107. @<Globals...@>=
  108. @!term_out:text_file; {the terminal as an output file}
  109. @y
  110. @z
  111.  
  112. @x
  113. rewrite(term_out,'TTY:'); {send |term_out| output to the terminal}
  114. @y
  115. print_ln(banner); {print a ``banner line''}
  116. @z
  117.  
  118. @x
  119. @d update_terminal == break(term_out) {empty the terminal output buffer}
  120. @y
  121. @d update_terminal == {emptying the screen output buffer is not necessary}
  122. @z
  123.  
  124. @x
  125. @ The following code opens |Pascal_file| and |pool|.
  126. Since these files were listed in the program header, we assume that the
  127. \PASCAL\ runtime system has checked that suitable external file names have
  128. been given.
  129. @^system dependencies@>
  130.  
  131. @<Set init...@>=
  132. rewrite(Pascal_file); rewrite(pool);
  133. @y
  134. @ The following code opens |Pascal_file| and |pool|.
  135. Actually, on the Atari ST this task is put off until later.
  136. @^system dependencies@>
  137. @z
  138.  
  139. @x
  140. @!string_ptr:name_pointer; {next number to be given to a string of length |<>1|}
  141. @y
  142. @!string_ptr:name_pointer; {next number to be given to a string of length |<>1|}
  143. @!k:integer; {extra loop variable}
  144. @z
  145.  
  146. @x
  147.   begin for loc:=0 to change_limit do buffer[loc]:=change_buffer[loc];
  148. @y
  149.   begin for k:=0 to change_limit do buffer[k]:=change_buffer[k];
  150. @z
  151.  
  152. @x
  153. @!term_in:text_file; {the user's terminal as an input file}
  154. @y
  155. @z
  156.  
  157. @x
  158. reset(term_in,'TTY:','/I'); {open |term_in| as the terminal, don't do a |get|}
  159. @y
  160. @z
  161.  
  162. @x
  163. print_ln(banner); {print a ``banner line''}
  164. @y
  165. @z
  166.  
  167. @x
  168. stat for zo:=0 to zz-1 do max_tok_ptr[zo]:=tok_ptr[zo];@+tats@;@/
  169. @y
  170. stat for k:=0 to zz-1 do max_tok_ptr[k]:=tok_ptr[k];@+tats@;@/
  171. @z
  172.  
  173. @x save pool and Pascal files only if they were written to.
  174. if string_ptr>128 then @<Finish off the string pool file@>;
  175. stat @<Print statistics about memory usage@>;@+tats@;@/
  176. @t\4\4@>{here files should be closed if the operating system requires it}
  177. @<Print the job |history|@>;
  178. end.
  179. @y
  180. if history<fatal_message then begin
  181.   if string_ptr>128 then begin @<Finish off the string pool file@>;
  182.     close(pool, true);
  183.   end;
  184.   close(Pascal_file, true);
  185. end;
  186. stat @<Print statistics about memory usage@>;@+tats@;@/
  187. @<Print the job |history|@>;
  188. wait(3);
  189. end.
  190. @z
  191.  
  192. @x
  193. for string_ptr:=1 to 9 do
  194. @y
  195. for k:=1 to 9 do
  196. @z
  197.  
  198. @x
  199. for string_ptr:=9 downto 1 do write(pool,xchr["0"+out_buf[string_ptr]]);
  200. @y
  201. for k:=9 downto 1 do write(pool,xchr["0"+out_buf[k]]);
  202. @z
  203.  
  204. @x
  205. for zo:=1 to zz-1 do print('+',max_tok_ptr[zo]:1);
  206. @y
  207. for k:=1 to zz-1 do print('+',max_tok_ptr[k]:1);
  208. @z
  209.  
  210. @x
  211. This module should be replaced, if necessary, by changes to the program
  212. that are necessary to make \.{TANGLE} work at a particular installation.
  213. It is usually best to design your change file so that all changes to
  214. previous modules preserve the module numbering; then everybody's version
  215. will be consistent with the printed program. More extensive changes,
  216. which introduce new modules, can be inserted here; then only the index
  217. itself will get a new module number.
  218. @y
  219. Here are the remaining changes to the program
  220. that are necessary to make \.{TANGLE} work on the Atari ST.
  221.  
  222. @ @<Local...@>=
  223. @!ask,@!name_found: boolean;
  224. @!file_name,@!job_name: string;
  225. @!name_length,@!name_index: integer;
  226.  
  227. @ Get the external file names, and then call |open|
  228. to associate an external file with each file variable.
  229.  
  230. @<Set init...@>=
  231. getcomm(job_name);
  232. name_length:=l @& e @& n @& g @& t @& h(job_name); name_index:=1;
  233. while (name_index <= name_length) and
  234.       (job_name[name_index] = ' ') do incr(name_index);
  235. name_found:=name_index <= name_length;
  236. if name_found then delete(job_name, 1, name_index-1);
  237.  
  238. if name_found then begin
  239.   file_name:=concat(job_name,'.WEB');
  240.   assign(web_file,file_name);
  241.   ask:=not fstat(file_name);
  242.   if ask then write_ln('Couldn''t open ',file_name);
  243. end
  244. else ask:=true;
  245. while ask do begin
  246.   write('Web file: ');
  247.   if eof then begin mark_fatal; jump_out; end;
  248.   read_ln(file_name);
  249.   if checkfn(file_name) then begin
  250.     ask:= not fstat(file_name);
  251.     if ask then write_ln('Couldn''t open ',file_name)
  252.            else assign(web_file,file_name);
  253.   end
  254.   else begin
  255.     ask:=true; write_ln('"',file_name,'" is not a good filename')
  256.   end;
  257. end;
  258.  
  259. if name_found then begin
  260.   file_name:=concat(job_name,'.CH');
  261.   assign(change_file,file_name);
  262.   ask:=not fstat(file_name);
  263.   if ask then write_ln('Couldn''t open ',file_name);
  264. end
  265. else ask:=true;
  266. while ask do begin
  267.   write('Change file: ');
  268.   if eof then begin mark_fatal; jump_out; end;
  269.   read_ln(file_name);
  270.   if file_name='' then file_name:='empty.ch';
  271.   if checkfn(file_name) then begin
  272.     ask:=not fstat(file_name);
  273.     if ask then write_ln('Couldn''t open ',file_name)
  274.            else assign(change_file,file_name);
  275.   end
  276.   else begin
  277.     ask:=true; write_ln('"',file_name,'" is not a good filename')
  278.   end;
  279. end;
  280.  
  281. if name_found then begin
  282.   file_name:=concat(job_name,'.PAS');
  283.   assign(Pascal_file,file_name);
  284.   ask:=not checkfn(file_name);
  285.   if ask then write_ln('"',file_name,'" is not a good filename')
  286. end
  287. else ask:=true;
  288. while ask do begin
  289.   write('Pascal file: ');
  290.   if eof then begin mark_fatal; jump_out; end;
  291.   read_ln(file_name);
  292.   ask := not checkfn(file_name);
  293.   if ask then
  294.     write_ln('"',file_name,'" is not a good filename')
  295.   else
  296.     assign(Pascal_file,file_name);
  297. end;
  298.  
  299. if name_found then begin
  300.   file_name:=concat(job_name,'.POO');
  301.   assign(pool,file_name);
  302.   ask:=not checkfn(file_name);
  303.   if ask then write_ln('"',file_name,'" is not a good filename')
  304. end
  305. else ask:=true;
  306. while ask do begin
  307.   write('Pool file: ');
  308.   if eof then begin mark_fatal; jump_out; end;
  309.   read_ln(file_name);
  310.   ask := not checkfn(file_name);
  311.   if ask then
  312.     write_ln('"',file_name,'" is not a good filename')
  313.   else
  314.     assign(pool,file_name);
  315. end;
  316.  
  317. rewrite(Pascal_file); rewrite(pool);
  318. @